<template>
    <!-- 浮动上下箭头子组件 -->
  <div class="scroll-arrow-container">
    <!-- 弹出区域 -->
    <div v-show="showConsultArea" class="consult-area">
      <!-- 微信咨询弹出框 -->
      <div class="wechat-popup" v-show="showWechatPopup">
        <div class="popup-title">扫码与您微信详聊</div>
        <div class="popup-content">
          <img src="../assets/qrcode_service.png" alt="微信二维码" />
        </div>
      </div>

      <!-- 电话咨询弹出框 -->
      <div class="phone-popup" v-show="showPhonePopup">
        <div class="popup-title">免费咨询热线</div>
        <div class="popup-content phone-content">
          <span>400-123-4567</span>
        </div>
      </div>

      <div
        class="consult-item left"
        @mouseenter="showWechatPopup = true"
        @mouseleave="showWechatPopup = false"
      >
        <div class="consult-icon">
          <img src="../assets/qrcode_service.png" alt="微信咨询" />
        </div>
        <span class="consult-text">微信咨询</span>
      </div>
      <div
        class="consult-item right"
        @mouseenter="showPhonePopup = true"
        @mouseleave="showPhonePopup = false"
      >
        <div class="consult-icon phone-icon"></div>
        <span class="consult-text">电话咨询</span>
      </div>
    </div>

    <div class="scroll-arrow" @click="toggleConsultArea">
      <div class="arrow-icon" :class="{ rotate: showConsultArea }">
        <img src="../assets/button_top.png" alt="" />
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "ScrollArrow",
  data() {
    return {
      showConsultArea: false,
      showWechatPopup: false,
      showPhonePopup: false,
    };
  },
  methods: {
    toggleConsultArea() {
      this.showConsultArea = !this.showConsultArea;
      // 关闭弹出框
      this.showWechatPopup = false;
      this.showPhonePopup = false;
    },
  },
};
</script>

<style scoped lang="scss">
/* 上下箭头容器 */
.scroll-arrow-container {
//   position: absolute;
  right: 60px; /* 轮播图最右边 */
  bottom: 290px; /* 轮播图指示箭头下面 */
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* 咨询区域样式 */
.consult-area {
  background-color: white;
  border-radius: 50px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  position: absolute;
  right: -5px;
  top: -160px;
  z-index: 10;
}

// 微信咨询弹出框
.wechat-popup {
  position: absolute;
  top: -150px; /* 左上角 */
  right: 100%;
  margin-right: 10px;
  width: 180px;
  background-color: white;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  padding: 15px;
  z-index: 20;
}

// 电话咨询弹出框
.phone-popup {
  position: absolute;
  bottom: 0; /* 左下角 */
  right: 100%;
  margin-right: 10px;
  width: 180px;
  background-color: white;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  padding: 15px;
  z-index: 20;
}

.popup-title {
  font-size: 14px;
  font-weight: bold;
  color: #333;
  text-align: center;
  margin-bottom: 10px;
}

.popup-content {
  display: flex;
  justify-content: center;
  align-items: center;
}

.popup-content img {
  width: 140px;
  height: 140px;
}

.phone-content {
  font-size: 18px;
  color: #1890ff;
  font-weight: bold;
}

.consult-item.left {
  padding: 18px 10px 8px 10px;
  border-top-left-radius: 50px;
  border-top-right-radius: 50px;
  position: relative;
  z-index: 15;
}
.consult-item.right {
  padding: 8px 10px 18px 10px;
  border-bottom-left-radius: 50px;
  border-bottom-right-radius: 50px;
  position: relative;
  z-index: 15;
}

.consult-item {
  display: flex;
  align-items: center;
  cursor: pointer;
  transition: background-color 0.3s ease;
  flex-direction: column;
}

.consult-item:hover {
  background-color: #f0f8ff;
}

.consult-icon {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.consult-icon img {
  max-width: 100%;
  max-height: 100%;
}

.phone-icon::before {
  content: "📞";
  font-size: 24px;
}

.consult-text {
  font-size: 10px;
  color: #333;
  white-space: nowrap;
}

/* 上下箭头样式 */
.scroll-arrow {
  width: 50px;
  height: 50px;
  background-color: #f6f6f6;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  position: relative;
  z-index: 5;
}

.scroll-arrow:hover {
  background-color: #d6d7d8;
}

/* 箭头图标 */
.arrow-icon {
  transition: transform 0.5s ease;
}

.rotate {
  transform: rotate(180deg);
}

.arrow-icon.rotate {
  transform: translateY(2px) rotate(180deg);
}
</style>